﻿<UserControl x:Class="Schedulr.Views.Controls.RenderingPreview"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Margin="0,5,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="1" HorizontalAlignment="Right" x:Name="previousButton" Click="previousButton_Click" Style="{StaticResource SmallButton}">
                <Image Source="/Resources/MoveLeft.png" Height="12" Width="12" Stretch="Uniform" />
            </Button>
            <StackPanel Grid.Column="2" Orientation="Horizontal" Margin="5,0,5,0">
                <TextBox MinWidth="40" x:Name="currentIndexTextBox" TextChanged="currentIndexTextBox_TextChanged" />
                <TextBlock VerticalAlignment="Center" Text="of ..." Margin="5,0,0,0" x:Name="totalCountTextBlock" />
            </StackPanel>
            <Button Grid.Column="3" HorizontalAlignment="Left" x:Name="nextButton" Click="nextButton_Click" Style="{StaticResource SmallButton}">
                <Image Source="/Resources/MoveRight.png" Height="12" Width="12" Stretch="Uniform" />
            </Button>
            <StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button x:Name="refreshButton" ToolTip="Refresh the preview" Click="refreshButton_Click" Style="{StaticResource SmallButton}">
                    <Image Source="/Resources/Refresh.png" />
                </Button>
                <Button x:Name="saveButton" ToolTip="Save a copy of the rendered file" Click="saveButton_Click" Style="{StaticResource SmallButton}">
                    <Image Source="/Resources/Save.png" />
                </Button>
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Slider Grid.Row="0" Orientation="Vertical" Margin="0,0,5,0" Minimum="0" Maximum="4" Value="0.25" LargeChange="0.25" SmallChange="0.01" TickPlacement="BottomRight" TickFrequency="0.25" x:Name="zoomSlider" Style="{StaticResource SmallSlider}" />
                <TextBlock Grid.Row="1" Text="{Binding ElementName=zoomSlider, Path=Value, StringFormat=p0}" FontSize="10" Foreground="{StaticResource InfoFontBrush}" Margin="0,5,0,0" />
            </Grid>
            <Border Grid.Column="1" Style="{DynamicResource BorderStyle}" Padding="5" Margin="0,5,0,5">
                <Grid>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                            <Grid>
                                <Grid x:Name="previewImageContainer" Visibility="Hidden">
                                    <Image x:Name="previewImage" Stretch="None">
                                        <Image.LayoutTransform>
                                            <TransformGroup>
                                                <ScaleTransform x:Name="dpiScaleTransform" />
                                                <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" ScaleY="{Binding Path=Value, ElementName=zoomSlider}" />
                                            </TransformGroup>
                                        </Image.LayoutTransform>
                                    </Image>
                                </Grid>
                                <Grid x:Name="previewVideoContainer" Visibility="Collapsed">
                                    <MediaElement Grid.Row="0" x:Name="previewVideo" IsMuted="False" Volume="{Binding ElementName=volumeSlider, Path=Value}" LoadedBehavior="Manual" MediaEnded="previewVideo_MediaEnded" MediaOpened="previewVideo_MediaOpened" MediaFailed="previewVideo_MediaFailed">
                                        <MediaElement.LayoutTransform>
                                            <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}" ScaleY="{Binding Path=Value, ElementName=zoomSlider}" />
                                        </MediaElement.LayoutTransform>
                                    </MediaElement>
                                </Grid>
                            </Grid>
                        </ScrollViewer>
                        <StackPanel Grid.Row="1" HorizontalAlignment="Center" Orientation="Vertical" Margin="0,5,0,5" x:Name="mediaInfoContainer">
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource InfoFontBrush}" TextWrapping="Wrap" TextAlignment="Center" x:Name="mediaInfoTextBlock" />
                            <Border Visibility="{Binding ElementName=previewVideoContainer, Path=Visibility}" Style="{DynamicResource BorderStyle}" Margin="5,5,0,0" Padding="5">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="videoPlayButton" Click="videoPlayButton_Click" Margin="0,0,5,0" Style="{StaticResource SmallButton}" ToolTip="Play">
                                        <Image Source="/Resources/MediaPlay.png" />
                                    </Button>
                                    <Button x:Name="videoPauseButton" Click="videoPauseButton_Click" Margin="0,0,5,0" Style="{StaticResource SmallButton}" ToolTip="Pause">
                                        <Image Source="/Resources/MediaPause.png" />
                                    </Button>
                                    <Button x:Name="videoStopButton" Click="videoStopButton_Click" Margin="0,0,5,0" Style="{StaticResource SmallButton}" ToolTip="Stop">
                                        <Image Source="/Resources/MediaStop.png" />
                                    </Button>
                                    <Slider Margin="0,0,5,0" Width="200" Minimum="0" x:Name="positionSlider" Style="{StaticResource SmallSlider}" ValueChanged="positionSlider_ValueChanged" Thumb.DragStarted="positionSlider_DragStarted" Thumb.DragCompleted="positionSlider_DragCompleted" />
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource InfoFontBrush}" x:Name="positionTextBlock" Margin="0,0,5,0" />
                                    <Image Source="/Resources/MediaVolume.png" />
                                    <Slider Width="50" Minimum="0" Maximum="1" Value="0.5" x:Name="volumeSlider" Style="{StaticResource SmallSlider}" />
                                </StackPanel>
                            </Border>
                        </StackPanel>
                    </Grid>
                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource InfoFontBrush}" TextWrapping="Wrap" TextAlignment="Center" x:Name="messageTextBlock" />
                </Grid>
            </Border>
        </Grid>
    </Grid>
</UserControl>